// 生成器函数回顾
function * foo() {
    console.log('start')

    // const res = yield 'foo'
    // console.log(res)
    try {
        const res = yield 'foo'
        console.log(res)
    } catch(e) {
        console.log(e)
    }
}

const generator = foo()

const result = generator.next()
console.log(result)

// generator.next('jqb')

generator.throw(new Error('Generator error'))